avoid NPE
refactor client protocol