Refactoring of shared code