Use hash tables to improve performance