readded S3 code