improve running time using IntMap