Faster N-gram Filtering Algo