[Refactoring] Small performance and readability improvement in data filtering.