Refactor show completion
Refactor document initialization