Modified for better handling of checkpoints