Improve mongo usage: make use of the connection pooling, and only perform the query once instead of twice per request