code duplication reduced