detstats() fix divided by zero