Fix loop in match method