Use hashes for 20% speedup