Please change to more numerically reliable and clean implementation (don't use pow(xx, float) )