move arrayBuffer declaration to 'query-end' function