refactoring doc_handelers.js