There are some implementation examples here:
Webhook Receivers: https://github.com/BarryCarlyon/twitch_misc/tree/master/webhooks/handlers
App Access Tokens: https://github.com/BarryCarlyon/twitch_misc/tree/master/authentication/app_access_tokens
Might be worth starting over than trying to modify, if you don’t know how it works enough to fix it and can’t trace it back, start over.
Build afresh.
Personally for this I’d move it to webhooks since you have a known list of streamers, then store the data in a database and recall it from that database, rather than each page load requiring API lookups