Added code for balance factor