Implemented error check on logical expressions