fixed a memory leak in the getState method