moving main chartcycle function into its own file, fixing variable declaration so its usable