map rewritten. refactoring (part 1 of 2)