remove code duplication