determine dir empty status more efficiently