private function _is_balanced($input) {
    $balance = 0;

    foreach ( str_split($input) as $char ) {
      if ( $char == '(' ) {
        $balance++;
      } else if ( $char == ')' ) {
        $balance--;
      }

      // found a close paren without a matching open paren,
      // no need to continue further
      if ( $balance < 0 ) {
        break;
      }
    }

    return $balance === 0;
  }