fixing syntax to prevent variable be global and removed not needed variable