fix saving bug and moved from dom to memory