Add Withdraw function and fix bug