Move isBalanced to brackets module