refactor to integrate Amazon S3