checking whether document is defined