The random and winstate checks can be pulled right to the start of the function, before creating the pilot actor.