factored restoretty into a module