implementation of exponentiation