removed pow(x, -1) and used 1.0 / x to increase speed