Minor optimization on filtering