replaced Vec with TreeMap