map and exists refactured