added commutativity checking for interal brackets and fixed the missing innermost bracket. Done.