refactored reset routine.