Move restart into a function