added better logic for calculating S3 urls