rev string and check for correct parentheses