refactored text indexing method so that it works properly and passes tests