refactored routing and relays