Refactoring around write commands and collection to insert documents