Fixed a possible divide by zero error