change protocol to support version 3
refactor