Changed math

Changed math as per bug report number 1.