updated api to use mongodb