move vars into correct scope