added scriptEnding callback