improved the custom upload dir function