trying to fix the memory leak. think i got it.