the main loop from findRedGreen, and a few variables that it needs