Refactor the mapping functions