Added exponentiation by squaring