Optimize condition matching