Fixed a possible divide by zero bug