analyze this code " function cleanOTCInput() {
  const inputSheetName = "OTC-Input"; // Name of the input sheet
  const outputSheetName = "CleanData"; // Name of the output sheet

  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const inputSheet = ss.getSheetByName(inputSheetName);
  let outputSheet = ss.getSheetByName(outputSheetName);

  // Create the output sheet if it doesn't exist
  if (!outputSheet) {
    outputSheet = ss.insertSheet(outputSheetName);
  } else {
    outputSheet.clear(); // Clear existing content
  }

  const data = inputSheet.getDataRange().getValues();
  const headers = data[0];

  // Columns to remove
  const removeColumns = [
    "Overtime 2 Hours", "Overtime 3 Hours", "Vacation Hours", "Holiday Hours",
    "Sick Hours", "Personal Hours", "First Punch In", "Last Punch Out",
    "Tip Amount", "Bonus Amount", "Commission Amount", "Mileage"
  ];

  // Filter out unwanted columns
  const keepIndexes = headers
    .map((header, index) => (removeColumns.includes(header) ? null : index))
    .filter(index => index !== null);

  // Keep only relevant data
  const filteredData = data.map(row => keepIndexes.map(index => row[index]));
  const filteredHeaders = keepIndexes.map(index => headers[index]);

  // Add new columns: Paid Hours and Total Hours (Paid + Overtime 1)
  const newHeaders = [...filteredHeaders];
  const regularHoursIndex = filteredHeaders.indexOf("Regular Hours");
  const ot1HoursIndex = filteredHeaders.indexOf("Overtime 1 Hours");

  newHeaders.splice(regularHoursIndex + 1, 0, "Paid Hours");
  newHeaders.splice(ot1HoursIndex + 2, 0, "Total Paid + OT1 Hours");

  // Write headers to the output sheet
  outputSheet.appendRow(newHeaders);

  let currentName = null;
  let groupData = [];
  let rowIndex = 2; // Start writing data from the second row (first row is headers)

  for (let i = 1; i < filteredData.length; i++) {
    const row = filteredData[i];
    if (row[0] !== currentName) {
      // Process the previous group
      if (groupData.length > 0) {
        rowIndex = writeGroup(outputSheet, groupData, newHeaders, regularHoursIndex, ot1HoursIndex, rowIndex);
      }
      // Start new group
      currentName = row[0];
      groupData = [];
    }
    groupData.push(row);
  }

  // Process the final group
  if (groupData.length > 0) {
    writeGroup(outputSheet, groupData, newHeaders, regularHoursIndex, ot1HoursIndex, rowIndex);
  }
}

function writeGroup(sheet, groupData, headers, regularHoursIndex, ot1HoursIndex, startRow) {
  const headersLength = headers.length;

  // Write group rows with new columns calculated
  const processedData = groupData.map(row => {
    const paidHours = Math.min(row[regularHoursIndex], 8); // Cap at 8
    const totalPaidOT1 = paidHours + (row[ot1HoursIndex] || 0);

    const newRow = [...row];
    newRow.splice(regularHoursIndex + 1, 0, paidHours);
    newRow.splice(ot1HoursIndex + 2, 0, totalPaidOT1);
    return newRow;
  });

  processedData.forEach((row, i) => {
    sheet.getRange(startRow + i, 1, 1, headersLength).setValues([row]);
  });

  // Calculate totals
  const totalRow = calculateTotals(processedData, headers, regularHoursIndex + 1, ot1HoursIndex + 2);
  const totalRowPosition = startRow + processedData.length;

  // Write total row and make it bold
  sheet.getRange(totalRowPosition, 1, 1, totalRow.length).setValues([totalRow]);
  sheet.getRange(totalRowPosition, 1, 1, totalRow.length).setFontWeight("bold");

  // Add a blank row for spacing
  const spacingRowPosition = totalRowPosition + 1;
  sheet.getRange(spacingRowPosition, 1, 1, headersLength).setValues([new Array(headersLength).fill('')]);

  return spacingRowPosition + 1; // Return the next starting row
}

function calculateTotals(groupData, headers, paidHoursIndex, totalPaidOT1Index) {
  const totalsRow = Array(headers.length).fill('');
  totalsRow[0] = "TOTAL"; // Label the first column

  // Calculate totals for numeric columns
  const numericIndexes = headers.map((header, index) =>
    ["Total Hours", "Regular Hours", "Paid Hours", "Overtime 1 Hours", "Total Paid + OT1 Hours"].includes(header)
      ? index
      : null
  ).filter(index => index !== null);

  numericIndexes.forEach(index => {
    const total = groupData.reduce((sum, row) => sum + (parseFloat(row[index]) || 0), 0);
    totalsRow[index] = total;
  });

  return totalsRow;
}
 "