Moved download code to a new method