fix possible divide by zero