correcting output directory handling