adding changes to better handle parentheses