integration with mongoDB, sort of, for square functions