refactor normalizing and word indexing