working version with debit and credit