fix directory checking