working on fixing a memleak/performance problem