Added +/- lookahead to algorithm.