refactor to use mongoDB