fix bug where variables would not properly reset