moved nested shell checking into its own file