Fixed a corner case

Had a mistake with the corner case for the balance function.