removed test code and optimised pow