If money or bonds have been deposited, bail by sureties may be substituted therefor at any time before a breach of the undertaking, and the official taking the new bail shall make an order that the money or bonds be refunded to the person depositing the same and they shall be refunded accordingly, and the original undertakings shall be canceled.
SDCL 58-22-42