fix a divide by zero bug