Use hash table for O(n)