ok that's basically what I was suggesting in the other comments.

I'll take some time to understand properly this code but right now I'm quite sure we don't need to use the contacts API for each term after all.