refactor tcp version