updating code with mongo group scan