 	printf("Copying postings from host to device\n");
 
   // POSTINGS TO DEVICE
-	checkCuda( cudaMalloc((void**)&d_postings, sizeof(Posting) * terms) );
-	checkCuda( cudaMemcpy(d_postings, postingsLoaded, sizeof(Posting) * terms, cudaMemcpyHostToDevice) );
+	checkCuda( cudaMalloc((void**)&dev_postings, sizeof(Posting) * terms) );
+	checkCuda( cudaMemcpy(dev_postings, postingsLoaded, sizeof(Posting) * terms, cudaMemcpyHostToDevice) );
 	int i;
-	int *d_docIds;
-	float *d_weights;
+	int *dev_docIds;
+	float *dev_weights;
 	for (i = 0; i < terms; i++) {
 		Posting p = postingsLoaded[i];
 
-		checkCuda( cudaMalloc((void**) &d_docIds, sizeof(int) * p.docsLength) );
-		checkCuda( cudaMalloc((void**) &d_weights, sizeof(float) * p.docsLength) );
-
-		checkCuda( cudaMemcpy(&(d_postings[i].docIds), &(d_docIds), sizeof(int *), cudaMemcpyHostToDevice) );
-		checkCuda( cudaMemcpy(&(d_postings[i].weights), &(d_weights), sizeof(float *), cudaMemcpyHostToDevice) );
-
-		checkCuda( cudaMemcpy(d_docIds, p.docIds, sizeof(int) * p.docsLength, cudaMemcpyHostToDevice) );
-		checkCuda( cudaMemcpy(d_weights, p.weights, sizeof(float) * p.docsLength, cudaMemcpyHostToDevice) );
+		checkCuda( cudaMalloc((void**) &dev_docIds, sizeof(int) * p.docsLength) );
+		checkCuda( cudaMalloc((void**) &dev_weights, sizeof(float) * p.docsLength) );
+
+		checkCuda( cudaMemcpy(&(dev_postings[i].docIds), &(dev_docIds), sizeof(int *), cudaMemcpyHostToDevice) );
+		checkCuda( cudaMemcpy(&(dev_postings[i].weights), &(dev_weights), sizeof(float *), cudaMemcpyHostToDevice) );
+
+		checkCuda( cudaMemcpy(dev_docIds, p.docIds, sizeof(int) * p.docsLength, cudaMemcpyHostToDevice) );
+		checkCuda( cudaMemcpy(dev_weights, p.weights, sizeof(float) * p.docsLength, cudaMemcpyHostToDevice) );
 
 	}
 

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;

		printf("doc %d: %4.2f\n", i, docScores[i]);
	}

	cudaFree(dev_queryTerms);
	cudaFree(dev_docScores);
  free(queryTerms);
}

