Moved extract and download to functions