Put debug variable population into its own function