Tested restart after winning and losing to see if the LCDclr was working properly. Changing the while statement to (flag > 4) corrected the problem. Required functionality working.