finally solve it use hash table, which is amazing. refer to others