Refactor uploading to S3