Don't calculate the same thing twice! Set ExploredUnits2=ExploredUnits. Use ELSE for your DiscoveryMod checks. It will reduce the number of tests, on average, and you'll only need the <= test for all but the first one. Do you really need to test those every tick? If not, use every 0.x seconds.