Added some local and global variables to access with threads