how should I fix this memory leak??