use better logic for peer detection