parentheses problem implementation