working on save checkpoint function