 		printf("doc %d: %4.2f\n", i, docScores[i]);
 	}
 
-	cudaFree(d_queryTerms);
-	cudaFree(d_docScores);
+	cudaFree(dev_queryTerms);
+	cudaFree(dev_docScores);
   free(queryTerms);
 }
 

void displayPosting(Posting *postings, int size);

// global variables that are allocated in device during indexing
Posting *d_postings;
float *dev_docsNorm;
int terms;
int docs;

    termPos++;
  }

  int *dev_queryTerms;
	float *docScores, *dev_docScores;
	int BLOCK_SIZE = 1024;
	int numBlocks = (docs + BLOCK_SIZE - 1) / BLOCK_SIZE;

	docScores = (float *) malloc(sizeof(float) * docs);
	cudaMalloc((void **) &dev_queryTerms, querySize * sizeof(int));
  cudaMalloc((void **) &dev_docScores, docs * sizeof(float));

  cudaMemcpy(dev_queryTerms, queryTerms, querySize * sizeof(int), cudaMemcpyHostToDevice);

	cudaEventRecord(resolveQueryStart);
	k_resolveQuery<<<numBlocks, BLOCK_SIZE>>>(
		dev_postings,
		dev_docsNorm,
		terms,
		docs,
		dev_queryTerms,
		querySize,
		dev_docScores
	);
	handleKernelError();
	cudaEventRecord(resolveQueryStop);

	cudaMemcpy(docScores, dev_docScores, docs * sizeof(float), cudaMemcpyDeviceToHost);

	cudaEventSynchronize(resolveQueryStop);
	float milliseconds = 0;
