added fast exponentiation