Moved download method to the top of the file