Optimising code to detect duplicates of a text. Original code created for a course assignment.