implemented word popularity calculation