Refactoring

Fix code duplication