improve reset logic