Refactor peering logic