create stage 6, refactor some code