added structure for dataSample and used array to iterate