Moved restarting to a seperate function.