improved balance calculating