added upload to S3 and better exception handling