improved checking whether resources exist