some Simple Implementation of isBalanced function