Changed code so it can process a larger data set