fixes potential divide-by-zero