solved potential memory leaks