Move task grouper code to it's own method