Pull out each command into its own function