fix directory reading bug