Changed the search structure to have periodic resoruce id in the outer loop and configured resource set as inner loop to prevent configuring resource that is not needed. Use const for input pointers.