fixed directory checking bug