fix potential divide by 0 in setting popularities