Added an onEnd callback