Fix divide by zero bug