remade save logic