Optimize selecting by attributes
subtle optimizations