my revision of their code to make it more like plsa