implement next match logic