made a different optimization by using sets rather than arrays when comparing n-grams, speeds up by a factor of 4