added logic for checking parens