Fix dead lock by storing the map