loadData function modified