moves switching between containers into its own method