rewrite navmap.py to remove double code