fix directory detection