final refactor reset function