refactored wire handler