Added condition for empty directory