more refactoring on wire side