Refactor trip controller