made some globals local