fixed memory leak during initialization