add check for null doc