Simplified unnecessary for loop to object lookup, and fixed a missing va...

...r declaration.