Fix division by zero problem