fixed bug that caused NPE when reading directory