Don't trigger server using integers of the element index on the array, that's a really bad idea.
Another thing, maybe make the function clientside? And triggerserver if needed, because most staff tools are clientside.
Good work though.