cannot use a resource as an array index