Converted some Global Variables into Local Variables