modified to query from mongo db