new version with safer reset state