public static Stack<Integer> findUnsafe(Bank[] bankList, double limit, Stack<Integer> unsafeBanks) {
		
		int c, l;
		boolean stateChanged = true; //initialization as true to get the logic going
		
		//if there's been a change in state, primarily a bank in the list has been flagged as unsafe
		//start from the beginning and check again
		//SOME OPTIMIZATION WORK CAN BE DONE HERE SO THE PROGRAM DOESN'T HAVE TO LOOP THROUGH EVERYTHING IF A
		//BANK IS UNSAFE
		while (stateChanged) {
		
			for (c = 0; c < bankList.length; c++) {
				
				if (bankList[c].unsafe == false) { //for the banks that have not been flagged as unsafe...
				
					bankList[c].currentBalance = bankList[c].baseBalance; //set the base balance as the current balance
					
					for (l = 0; l <bankList[c].loanList.length; l++) {
					
						//add the value of all loans the bank has given out to the the current balance
						bankList[c].currentBalance += bankList[c].loanList[l].amount;
						
					}
					
					System.out.println("Bank " + c + " current balance is " + bankList[c].currentBalance + ".");
					
					//checks if the balance of the bank is under the limit
					if (bankList[c].currentBalance < limit) {
						
						//if under the limit, the bank is pushed in the stack and flagged as unsafe
						unsafeBanks.push(c);
						bankList[c].unsafe = true;
						stateChanged = true; //flags that there's been a change in the bankList and the program should recalculate the values of all the banks again
						updateUnsafe(bankList, c); //calls a method that goes through the bankList and invalidates the loan amounts other banks have given to the unsafe bank
						break;
						
					} else {
						
						//all the banks have been checked if they are safe or not
						stateChanged = false;
						
					}
				}
			}
		}
		
		return unsafeBanks; //returns the stack of unsafe banks to main
	}