diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java
index 0a35373..fe42076 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java
@@ -23,10 +23,21 @@
  */
 package org.onap.appc.adapter.iaas.provider.operation.impl;
 
+import static org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation.ATTACHVOLUME_SERVICE;
 import static org.onap.appc.adapter.utils.Constants.ADAPTER_NAME;
-import java.util.Map;
-import java.util.List;
+
+import com.att.cdp.exceptions.ZoneException;
 import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.VolumeService;
+import com.att.cdp.zones.model.ModelObject;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Volume;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import java.util.List;
+import java.util.Map;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.onap.appc.Constants;
 import org.onap.appc.adapter.iaas.ProviderAdapter;
@@ -39,109 +50,97 @@
 import org.onap.appc.exceptions.APPCException;
 import org.onap.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import com.att.cdp.exceptions.ZoneException;
-import com.att.cdp.zones.Context;
-import com.att.cdp.zones.VolumeService;
-import com.att.cdp.zones.model.ModelObject;
-import com.att.cdp.zones.model.Server;
-import com.att.cdp.zones.model.Volume;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
-import static org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation.ATTACHVOLUME_SERVICE;;
 
 public class AttachVolumeServer extends ProviderServerOperation {
+
     private final EELFLogger logger = EELFManager.getInstance().getLogger(AttachVolumeServer.class);
 
     private Server attachVolume(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
         Server server = null;
-        RequestContext rc = new RequestContext(ctx);
-        rc.isAlive();
+        RequestContext requestContext = new RequestContext(ctx);
+        requestContext.isAlive();
         String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
-        String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
-        String volumeid = params.get(ProviderAdapter.VOLUME_ID);
+        String vmUrl = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+        String volumeId = params.get(ProviderAdapter.VOLUME_ID);
         String device = params.get(ProviderAdapter.DEVICE);
-        VMURL vm = VMURL.parseURL(vm_url);
-        Context context = null;
+        VMURL vm = VMURL.parseURL(vmUrl);
+        Context context;
         String tenantName = "Unknown";// to be used also in case of exception
         try {
-            if (validateVM(rc, appName, vm_url, vm))
+            if (validateVM(requestContext, appName, vmUrl, vm)) {
                 return null;
+            }
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
-            String vol_id = (volumeid == null) ? null : volumeid.toString();
-            context = getContext(rc, vm_url, identStr);
+            context = getContext(requestContext, vmUrl, identStr);
             if (context != null) {
-                tenantName = context.getTenantName();// this varaible also is used in case of exception
-                rc.reset();
-                server = lookupServer(rc, context, vm.getServerId());
-                logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+                tenantName = context.getTenantName();// this variable also is used in case of exception
+                requestContext.reset();
+                server = lookupServer(requestContext, context, vm.getServerId());
+                logger.debug(Msg.SERVER_FOUND, vmUrl, context.getTenantName(), server.getStatus().toString());
                 Context contx = server.getContext();
                 ComputeService service = contx.getComputeService();
-                VolumeService vs = contx.getVolumeService();
-                logger.info("collecting volume status for volume -id:" + vol_id);
-                List<Volume> volList = vs.getVolumes();
-                logger.info("Size of volume list :" + volList.size());
-                if (volList != null && !volList.isEmpty()) {
-                    for (Volume v : volList) {
-                        logger.info("list of volumesif exists" + v.getId());
-                        if (!v.getId().equals(vol_id)) {
-                            v.setId(vol_id);
-                            logger.info("Ready to Attach Volume to the server:" + Volume.Status.ATTACHING);
-                            service.attachVolume(server, v, device);
-                            logger.info("Volume status after performing attach:" + v.getStatus());
-                            if (validateAttach(vs, vol_id)) {
-                                doSuccess(rc);
-                            }
-                        } else {
-                            String msg = "Volume with volume id " + vol_id + " cannot be attached as it already exists";
-                            logger.info("Alreday volumes exists:");
-                            doFailure(rc, HttpStatus.NOT_IMPLEMENTED_501, msg);
-                        }
+                VolumeService volumeService = contx.getVolumeService();
+                logger.info("Collecting volume status for volume id: " + volumeId);
+                List<Volume> volumes = volumeService.getVolumes();
+                logger.info("Size of volume list: " + volumes.size());
+                for (Volume volume : volumes) {
+                    logger.info("Processing volume with id: " + volume.getId());
+                    if (!volume.getId().equals(volumeId)) {
+                        volume.setId(volumeId);
+                        logger.info("Ready to Attach Volume to the server: " + Volume.Status.ATTACHING);
+                        service.attachVolume(server, volume, device);
+                        logger.info("Volume status after performing attach: " + volume.getStatus());
+
+                        validateAttach(volumeService, volumeId, requestContext);
+                    } else {
+                        String msg = "Volume with id: " + volumeId + " cannot be attached as it already exists";
+                        logger.info(msg);
+                        doFailure(requestContext, HttpStatus.NOT_IMPLEMENTED_501, msg);
                     }
                 }
                 context.close();
-                doSuccess(rc);
+                doSuccess(requestContext);
                 ctx.setAttribute("VOLUME_STATUS", "SUCCESS");
             } else {
                 ctx.setAttribute("VOLUME_STATUS", "CONTEXT_NOT_FOUND");
             }
         } catch (ZoneException e) {
-            String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+            String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vmUrl);
             logger.error(msg);
-            doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+            doFailure(requestContext, HttpStatus.NOT_FOUND_404, msg);
         } catch (RequestFailedException e) {
-            doFailure(rc, e.getStatus(), e.getMessage());
+            logger.error("An error occurred in attachVolume", e);
+            doFailure(requestContext, e.getStatus(), e.getMessage());
         } catch (Exception ex) {
             String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, ex, ex.getClass().getSimpleName(),
-                    ATTACHVOLUME_SERVICE.toString(), vm_url, tenantName);
+                ATTACHVOLUME_SERVICE.toString(), vmUrl, tenantName);
             logger.error(msg, ex);
-            doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+            doFailure(requestContext, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
         }
         return server;
     }
 
     @Override
     protected ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context)
-            throws APPCException {
+        throws APPCException {
         setMDC(Operation.ATTACHVOLUME_SERVICE.toString(), "App-C IaaS Adapter:attachVolume", ADAPTER_NAME);
         logOperation(Msg.ATTACHINGVOLUME_SERVER, params, context);
         return attachVolume(params, context);
     }
 
-    protected boolean validateAttach(VolumeService vs, String volId) throws RequestFailedException, ZoneException {
-        boolean flag = false;
+    private void validateAttach(VolumeService vs, String volId, RequestContext requestContext)
+        throws RequestFailedException, ZoneException {
+
         List<Volume> volList = vs.getVolumes();
         for (Volume v : volList) {
             if (v.getId().equals(volId)) {
-                logger.info("Volume with " + volId + "attached successsfully");
-                flag = true;
+                logger.info("Volume with id: " + volId + " attached successfully");
+                doSuccess(requestContext);
             } else {
-                logger.info("failed to attach volume with id" + volId);
-                flag = false;
+                logger.info("Failed to attach volume with id: " + volId);
             }
         }
-        return flag;
     }
 
 }
