Fixed Bug in Balance Factor Calculation