fix a division-by-zero crash