refactoring documents_controller.