simple Implementation of isBalanced Function