change data vector to a iterator

change to iterator to handle large data set