Refactor part of the code.