Changed variables to global