attempting to break apart upload_directories into smaller functions
cleaned up the excess code for smaller functions