restructure mongo queries