refactor to play better with gensim's API