working on freeing memory