removed unused variable
removed memory leaks