more error checking when iterating over directories