refactor stage 9