Storing all docs in db. Refactoring