refactor the code to fetch data from website