I think this would be a lot simpler with one regex run once over the entire `output`.  I think this will work perfectly if you use a regex `^bound to (\S+)$` or something very similar to that.