refactored code in partDidst
parts of the matrix that are the same between two consecutive words are now kept