Fix utility method to check for directories rather than files.