moved variables to global