Trying to fix logic error with exponentiate