Moved variables to top of file