refactor duplication