optimize code for DataProvider class