Add check for division by zero