Fix the potential issue of switching map