Fix binding attributes to matching positions.
Merge pull request #751 from c0d1f1ed/fix-discard-in-loop

Fix binding attributes to matching locations.