recode the download and loadpage function