I think you want to search it in O(1) rather than O(n) here :-)