Refactor exponent matching