peer connection code more organized