Modified code for balance as this implementation is a lot simpler