public OperationResult buildVisualizationUsingGenericQuery(QueryRequest queryRequest) {
 
     OperationResult returnValue = new OperationResult();
-    OperationResult dataCollectionResult = new OperationResult();
+    OperationResult dataCollectionResult;
     QueryParams queryParams = null;
     SearchableEntity sourceEntity = null;
 
       dataCollectionResult = new OperationResult(500, "Failed to get nodes-query result from AAI");
     }
 
-    if (dataCollectionResult.getResultCode() == 200) {
+    if (dataCollectionResult == null || dataCollectionResult.getResultCode() == 200) {
 
       String d3OutputJsonOutput = null;