update data sturcture and memory management partly