Refactor document