use O(1) hashmap instead of O(n) list