Correct handling of nested ( ) pairs in logical statements