Added a check for directories