balanced function - for paren matching