refactor some code.