Divide by zero bug fix