refactor protocol