Implemented paren balancing algorithm