Changed the location of functions and variables

Still cannot see variables inside timer function