Refactor and edit comments.
Refactor group logic into separate method.