Add guard for division by zero