Refactor to split to 3 steps:
fetch, group, process