fix bug for dividing by zero