fix balance calculation