 		 column_vector::const_iterator i = shortData.begin();
 		 column_vector::const_iterator iorig = i;
 		 double sum = 0;
+
+		 for (; i - iorig != elem_count; i++) {
+		     sum += (*i) * (*i);
+		 }
+		 sum /= sqrt(sum);
+		 sum *= fabs(iorig[elem_count]) * 1e-5;
+		 i = shortData.begin();	
 		 for (int y = 0; y < SHORT_SIDE / 2 + SHORT_SIDE % 2; y++)
 		 {
 			for (int x = 0; x < SHORT_SIDE; x++)
 			{
-				sum += fabs(*i);
-				data[y * SIDE + x].x = *(i);
-				data[(SIDE * (SHORT_SIDE - y - 1)) + SHORT_SIDE - x - 1].x = *(i);
+				data[y * SIDE + x].x = *(i) / sum;
+				data[(SIDE * (SHORT_SIDE - y - 1)) + SHORT_SIDE - x - 1].x = *(i) / sum;
 				i++;
 
-				data[y * SIDE + x].y = *(i);
-				data[(SIDE * (SHORT_SIDE - y - 1)) + SHORT_SIDE - x - 1].y = -*(i);
-				sum += fabs(*i);
+				data[y * SIDE + x].y = *(i) / sum;
+				data[(SIDE * (SHORT_SIDE - y - 1)) + SHORT_SIDE - x - 1].y = -*(i) / sum;
 				i++;
 				if (i - iorig >= elem_count) goto end;
 			}

		double val = thrust::transform_reduce(thrust::make_zip_iterator(thrust::make_tuple(t_truePattern, t_mask, t_pattern)),
                                         thrust::make_zip_iterator(thrust::make_tuple(&t_truePattern[SIDE * SIDE], &t_mask[SIDE * SIDE], &t_pattern[SIDE * SIDE])), likelihooder,
					 (double) 0, thrust::plus<double>()) /*+ 34154. * SIDE * SIDE*/;
		printf("VAL %le %le\n", sum, val);
		static int count = 0;
		count++;
		if (!(count & 255)) fflush(stdout);

	int chosen = 0;
	int skips = 0;
	column_vector guess;
	guess.set_size(elem_count + 1, 1);
	guess(elem_count) = 1;
	for (int y = 0; y < SHORT_SIDE / 2 + SHORT_SIDE % 2; y++)
	{
		for (int x = 0; x < SHORT_SIDE; x++)
