function _deleteDocument (uint _id) internal {
        Document storage docToDelete = documents[_id];
        require (_id > 0);
        require(docToDelete.published);
        
        if (docToDelete.index < (documentsIndex.length).sub(1)) {
            
            uint lastDocId = documentsIndex[(documentsIndex.length).sub(1)];
            Document storage lastDoc = documents[lastDocId];
            
            documentsIndex[docToDelete.index] = lastDocId;
            
            lastDoc.index = docToDelete.index;
        }
        
        documentsIndex.length --;
        
        docToDelete.published = false;
        
        emit DocumentRemoved(_id);
    }