I'd suggest defining the onGet method outside the loop, for performance and memory.