refactor the code about proto