putting all together in queryManager.