refactor with reset