extract end of turn logic into its own function