Buggy code: checkpoint not working