refactoring datastore to use mongodb