added balance calculation