Fixed matchnum+1 bug