good whack at the race algorithm