completed loadData function