cleaned up the map code