 	blocksize = 100;
 
 #if MODE == 1
-	Matrix device_MatrixAp, device_MatrixCA, device_state1, device_state2, device_tmp_state, device_output_chunk;
+	Matrix device_MatrixAp, device_MatrixCA, device_state_read, device_state_write, device_tmp_state, device_output_chunk;
 
 	device_MatrixCA = m_new(blocksize, MatrixA.cols);
 	device_output_chunk = m_new(blocksize,1);
 	device_MatrixAp = m_new(MatrixA.rows, MatrixA.cols); // BLOCKDIAGMATRIX
-	device_state1 = m_new(2 * filters, 1);
-	device_state2 = m_new(2 * filters, 1);
+	device_state_read = m_new(2 * filters, 1);
+	device_state_write = m_new(2 * filters, 1);
 #endif
 
 	MatrixCA = m_new(blocksize, MatrixA.cols);

		for(j = 0; j < blocksize; j++) {
			output[i+j] = m_get(output_chunk,j,0)/128;
		}
		MatrixMultiplyKernel<<<dimGridA, dimBlockA>>>(device_MatrixAp, device_state1, device_state2);
		device_tmp_state = device_state1;
		device_state1 = device_state2;
		device_state2 = device_tmp_state;
#else
		/*
	       	 * CPU IMPLEMENTATION

	       	 * CUDA IMPLEMENTATION
		 */

		MatrixMultiplyKernel<<<dimGridCA, dimBlockCA>>>(device_MatrixCA, device_state_read, device_output_chunk);

		cudaDeviceSynchronize();	
		cudaMemcpy(output_chunk.elements, device_output_chunk.elements, m_size(output_chunk), cudaMemcpyDeviceToHost);
