fix directory handling