Refactoring to mongo