Right now it is assuming that the loop name is always going to be primary loop. See if this can be passed in