refactor submapper and add test case for submapper.