separated attribute matching and added tests