refactor the code.