Changed while loop to for loop in GetPreferredAction