use a map to solve problem