refactor protocol selection