refactor transport code