Add guard for division by zero
modif from sogiuser5