modifying for datasets larger than GPU memory