added some better reset logic