group functions together

put undo_snapshot in appropriate places