Properly iterate over and apply all matches