added fork condition to win
minor changes to reordering