fix a divide by 0 bug