add logic around s3 retrieval