i forgot; this is in a 18f4431 running at 40mhz. i also tried all kinds of different speeds, but same results; program on main routine will not run

Code:
BUTTONS:
GRID.0(SCAN) = 0
IF SCAN >= 39 THEN
SCAN = 0
ELSE
SCAN = SCAN + 1
ENDIF
GRID.0(SCAN)= 1
after more troubleshooting, i found out that its the line highlighted with red that's causing the program not to go to the main loop. any workaround?