refactor stage 1