If money has been deposited and it remains on deposit at the time of recovery of a judgment in favor of the plaintiff, the clerk shall, under direction of the court, apply the money in satisfaction of the judgment and, after satisfying the judgment, refund the surplus, if any, to the defendant. If the judgment is in favor of the defendant, the clerk shall, under the direction of the court, refund the whole sum deposited and remaining unapplied to the defendant.
§ 27-16-604, MCA