Hey guys

So I'm writing a program for some spacer discs, and I ran into a slight problem at the end.

The end part consist of three tools.
First turret B cuts an inside grove, then it gets a nylon bar to catch the part. The nylon bar and the cut off tool in turret A goes to their positions, cuts of the part and both tools goes to tool change positions.
At the end there's a loop to make the tools do the same for a preset number of parts.

-- CODE --
G13 (TURRET A)
..
..
V1=1
N001 T0101 P02 (CUT OFF TOOL)
--CUT OFF-- P03
G00 X900 Z500 P04
V1=V1+1
IF [V1 LT -NUMBER OF PARTS-] N001 P05
M05 M02

G14 (TURRET B)
..
..
V2=1
N002 T0101 P01 (INNSIDE GROVING TOOL)
--CUTTING INNSIDE GROVE--
G00 X900 Z500
T0202 P02 (BAR FOR CATCHING RING)
G00 --INSIDE TUBE-- P03
GOO X900 Z500 P04
V2=V2+1
IF [V1 LT -NUMBER OF PARTS-] N002 P05
M05
M02
----

When the machine tries to loop I get a priority code mismatch. I'm guessing this is because it's trying to go from a P05 to a P01, but I don't know how to solve it. Any ideas?