moved variables to toplevel