modified for mongodb.