I\'m trying to pass a class based on the url. At the moment the 2 for-loops are excicuted at all times. Is there a way to write it cleaner to avoid executing any unnecessary