updated check parens general case using stack script