fixing bugs on map/insertion