add check instanceof Document