stop infinite loops for directories