smarter empty dir check