how to refactor code