rewrote queries in mongodb, not tested but compiles