Fixed error in directory checking.