fix bug in searching for the next checkpoint