added logic for exponentiation