I want my Java Program to return a String response based on if/else conditions but it only responds to the last element in the ArrayList.
I have been working on this for two days without success. 
I will appreciate a direction as to what am doing wrongly. Thank You

```
import java.io.IOException;
import java.util.logging.Logger;

public class ScanUtility implements IScanUtility { 

    Logger logger = Logger.getLogger("ScanUtility"); 

    private  String performHostScan(String nodeName) {   

         Process OSCmdProcess = null; 
         Integer exitValue = null;
         String OScmd = null;
         String exitMessage = null;

        String OScmd = new String("/usr/bin/ssh ansible@" + nodeName + " " + "/tmp/openscapscan.bash rheldisa"); 

        try {
            OSCmdProcess = Runtime.getRuntime().exec(OScmd);
             exitValue = OSCmdProcess.waitFor(); 
            if (exitValue.equals(0)) {  

                exitMessage = ("Succeeded on" + " " + nodeName);
                return exitMessage; 
              } else {
                  exitMessage =  ("Failed on" + " " + nodeName);
                return exitMessage;
            }
        } catch (IOException ioExcep) {
            ioExcep.printStackTrace();
        } catch (InterruptedException interExcep) {
            interExcep.printStackTrace();
        }
        return exitMessage;

    }  

       //This method takes an ArrayList of hosts from the servlet controller
      // and passes the list to the ScanUtility Method above
      //============================================================
     public String generateHostName(List<String>  addressList){  
           String statusMessage = null;
          for(String nodeName: addressList){         
              statusMessage =  new ScanUtility().performHostScan(nodeName);
          }
        return statusMessage;                 
      }
}

```