protocol refactoring js side