refactoring build_vocab