update the logic to handle the files stroed on S3