js file for replay function