refactor document layout