refactor tcp proxy