Refactoring common code