         float secretElement = secretKey[ty * matrix_dims + k];
         float msgElement = msg[k * matrix_dims + tx];
         
-        printf("\nMultiplying %f by %f: \n", secretElement, msgElement);
+   //     printf("\nMultiplying %f by %f: \n", secretElement, msgElement);
         Pvalue  += secretElement * msgElement;
     }
     
-    printf("PValue: %f\n", Pvalue);
-    result[ty * matrix_dims + tx] = (int)Pvalue%ASCII_CHARS;
-    printf("result: %f\n", result[ty * matrix_dims + tx]);
+    //printf("PValue: %f    %d     %d\n", Pvalue, (int)Pvalue, ((int)Pvalue%ASCII_CHARS+ASCII_CHARS)%ASCII_CHARS);
+    int mod_result = ((int)Pvalue%ASCII_CHARS+ASCII_CHARS)%ASCII_CHARS; // actual modulus function
+    result[ty * matrix_dims + tx] = mod_result;
+   // printf("result: %f\n", result[ty * matrix_dims + tx]);
 }
 
 void secretKey(float **SKey, float **invSKey, int matrix_dims) {

#define ASCII_CHARS 128



void printrow(float *msg_v_list) {
    int i;


    cudaMemcpy(secretGpu, *invSKey, nBytes, cudaMemcpyHostToDevice);
    for (i = 0; i < msg_parts; i++) {
        cudaMemcpy(msgGpu, results[i], nBytes, cudaMemcpyHostToDevice);
        mtxEncrypt<<<grid, block>>>(secretGpu, msgGpu, resultGpu, matrix_dims);
        cudaMemcpy(unEncrypted[i], resultGpu, nBytes, cudaMemcpyDeviceToHost);
        cudaDeviceSynchronize();
    }
    for (i = 0; i < msg_parts; i++) {
        for (j = 0; j < matrix_size; j++) {
            printf("%c", (int)unEncrypted[i][j], char((int)unEncrypted[i][j]));
        }
    }
    free(results);
