handle div by zero

CC @cedk