First implementation of algorithm. Need better checkPoint.