V2

use HashMAp to improve efficiency