refactored to make a more generic uploader