move vars out of functinon