started to refactor the mapping code for easier understanding
started to refactor the mapping code for easier understanding