moved protocol detection to own method