GenerateCheckpoint function refactorized