I have this trigger for when a player selects a shop it will change them to another shop based on what hero they have. However I cant figure out how todo a few things
1) optimize this

there are so many loops there seems like there should be a better way...
2) if the player selects a shop that isnt the correct one it will correct it (ex a player selects Hero_Market[1] and has Hero_Type[2])
The variables are
Hero_Market[] Unit array
Hero_Type[] Unit type array
I have managed to get the main shop reselect working however the reselect i cant manage to get it to work without creating an endless loop
PS: yes i know it leaks ill fix that later tho