 							int j = 0;
 							for(j = 0; j < num_payouts; j++) {
 								if(isWin(device_payouts[j], lines[i])) {
+ 									device_payout_frequencies[a_index] += 1;
 									int k = 0;
 									double probability = 1.0;
 									for(k = 0; k < NUM_REELS; k++) {

       	exit(EXIT_FAILURE);
    }

    //invoke the device code
    int threadsPerBlock = num_symbols_per_reel;
    printf("**Calculating expected value on %d device threads\n", threadsPerBlock);    
    int blocksPerGrid = 1;//(numElements + threadsPerBlock - 1) / threadsPerBlock;
    calculateExpectedValue<<<blocksPerGrid, threadsPerBlock>>>(num_symbols_per_reel, num_payouts, total_choices,
    		device_possible_lines, device_symbols_weights, device_payouts, device_expected_values);
    error = cudaGetLastError();
    if (error != cudaSuccess) {
    	fprintf(stderr, "Failed to launch calculateExpectedValue kernel (error code %s)!\n", cudaGetErrorString(error));

        }
        printf("expected value for line %d: %f\n", i+1, expected_value/(i+1));
    }

    //copy device payout frequencies to host payout frequencies
    error = cudaMemcpy(payout_frequencies, device_payout_frequencies, num_symbols_per_reel * sizeof(int), cudaMemcpyDeviceToHost);
    if (error != cudaSuccess){
        fprintf(stderr, "Failed to copy payout frequencies %d from device to host (error code %s)!\n", i, cudaGetErrorString(error));
        exit(EXIT_FAILURE);
    }
    
    //sum each device payout frequency into one frequency
    int payout_frequency = 0;
    for(i=0; i < num_symbols_per_reel; i++) {
        payout_frequency += payout_frequencies[i];
    }
    double p = payout_frequency / (1.0 * total_choices);
    printf("payout frequency: %d. total spins: %d. percentage %f\n", payout_frequency, total_choices, p);
        
    //free host and device memory
    free(symbols_weights);
    free(payouts);
    free(expected_values);
    free(payout_frequencies);
    cudaFree(device_possible_lines);
    cudaFree(device_symbols_weights);
    cudaFree(device_payouts);
    cudaFree(device_expected_values);
    cudaFree(device_payout_frequencies);

    cudaDeviceReset();

