     printf("1\n");
     float **results = (float **)malloc(msg_size * sizeof(float *));
     printf("2\n");
-    for (z = 0; z < msg_size/matrix_size; z++) {
+    for (z = 0; z < msg_parts; z++) {
         results[z] = (float *)malloc(matrix_size * sizeof(float));
         memset(results[z], 0, nBytes);
     }

    cudaMalloc((void **)&secretGpu, nBytes);


    printf("msg_size/matrix_size: %d \n", msg_size/matrix_size);
    printf("\nmsg_vector_list[1]: %d\n", *msg_vector_list[1]);



    dim3 block(matrix_dims, matrix_dims);
    dim3 grid((matrix_dims+block.x-1)/block.x, (matrix_dims+block.y-1)/block.y);

    for (i = 0; i < msg_parts; i++) {
        cudaMemcpy(msgGpu, msg_vector_list[i], nBytes, cudaMemcpyHostToDevice);
        mtxEncrypt<<<grid, block>>>(secretGpu, msgGpu, resultGpu, matrix_dims);
        cudaMemcpy(results[i], resultGpu, nBytes, cudaMemcpyDeviceToHost);
