Refactor UpdateMap method