public static int findMax(int[][] matrix) {
		int[][] ps = buildPartialSumMatrix(matrix);
		System.out.println("partial sum matrix");
		AssortedMethods.printMatrix(ps);

		int maxSum = Integer.MIN_VALUE;
		for(int i=0; i<matrix.length; i++){
			for(int j=0; j<matrix[i].length; j++){
				for (int i2 = i; i2 < matrix.length; i2++){
					for (int j2 = j; j2< matrix[i2].length; j2++){
						int currSum;
						if(i==0 && j==0){
							currSum = ps[i2][j2];
						} else if(i==0){
							currSum = ps[i2][j2] - ps[i][j - 1];
						} else if(j==0){
							currSum = ps[i2][j2] - ps[i-1][j];
						} else{
							currSum = ps[i2][j2] - ps[i2][j - 1] - ps[i - 1][j2] + ps[i][j];
						}

						if(currSum > maxSum){
							System.out.println("Max found at (" + i + ", " + j + ") and ("+ i2 + ", " + j2 + ")");
							maxSum = currSum;

						}
					}
				}
			}
		}
		return maxSum;
	}