Remove code duplication