Cleaned up download function a little