Created restart function
Also calling the function from the thresholdcheck