refactor some portion of code