added some code for handling parenthases