refactored withdrawl function