fix possible division by zero