fixed memory leak bug by refactoring activate function in state class/all tests passing