fixed OOM Error for large dataset