fixes serious memory leak