updated query criteria for mongodb and added exceptions