Changed logic for directory read.