refactor mapper code