refactor res mapping