For loops inside getRange call

I am sorting through data collected on a master sheet, and then placing it in separate sheets based on those values. The sorting and placing the data into lists isn’t the issue.

I’m having trouble figuring out how to loop the placement of the data into the separate sheets. The data is already separated into lists in 2D arrays. Below is a shortened version of myt code, and at the end is the hard coded solution, but I should be able to accomplish this in a loop, right?

Ideally I should be able to run a loop through the lists and place the sorted data into the separate sheets.

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var ml = ss.getSheetByName('Master List');
  var lists = ["list1","list2];
  var masterlist = ml.getRange(2,2,100,100).getValues();
  var list1 = [];
  var list2 = [];
    for(i=0;i<masterlist.length;i++) {
      if(masterlist[i][2]==lists[0]){
        adminSec.push(masterlist[i])
      }
      if(masterlist[i][2] == lists[1]){
        math.push(masterlist[i])
      }
    }
  ss.getSheetByName(domains[0]).getRange(2,2,list1.length,list1[0].length).clearContent();
  ss.getSheetByName(domains[0]).getRange(2,2,list1.length,list1[0].length).setValues(list1);
  ss.getSheetByName(domains[1]).getRange(2,2,list2.length,list2[0].length).clearContent();
  ss.getSheetByName(domains[1]).getRange(2,2,list2.length,list2[0].length).setValues(list2);