fixing performance issue with large datasets