improve reset function