Added code to conditionally download files