Motor/encoder calculations - Accell, Decell and Stopping Distance

You could use the AccelStepper library, keep track of the encoder counts while in your stepper.run() loop, then correct / stop / restart if what you expected to see isn't what the encoder says it sees.

Good luck!