changing attribute and then setting it back to what it was

i want to know how would you approach changing some attribute of a mob and then setting it back to what it was. the only thing i could think of, is this: think of a zombie named bob. now before changing his attribute i am first going to append a new compound entry in an array {uuid:[],value:0b} then i would store bob's attribute value and uuid into that compound. then i will change the attribute to whatever value i want. now, if i wanna change the attribute back to what it was, i would iterate over the array until uuid matches to that of bob, and then via macros i would set his attribute back to what it was. this would certainly work, but i dont think this is the most efficient solution, and i hope to get some help brainstorming a better perfoming solution
Continue to help post