implement bag of words