Actually in the code I posted if (%tube.line < 7) { inc %tube.line } should be if (%tube.line != $null) && (%tube.line < 7) { inc %tube.line }