smarter empty directory check