complete the auto save function