refactor to mongodb