I think that ENDPOINTS[item]['ipv4'] is an array so it's supposed to hold more than one ip. I would change this so that it allows more than just one eendpoint.