then refactor the code