I don't know, because segment is already attached to $scope (https://github.com/elasticsearch/kibana/blob/master/src/app/panels/table/module.js#L222)

This refactor came as I extracted the callback from get_data. Maybe we can refactor even more to remove the variable from $scope