Add mapGroup comment and refactor