Changed calls to Math.pow(), original code being ported in was misread