Working properly for large dataset