Moved varaibles to the right scope