}
 
                        } catch (IOException e) {
-
-                               e.printStackTrace();
+                               LOGGER.error("Error in callUpdateMirrorMaker:", e);
                        }
                }
                // Send error response if user does not provide Authorization
                                                inStream = IOUtils.toInputStream(jsonOb.toString(), "UTF-8");
 
                                        } catch (IOException ioe) {
-                                               ioe.printStackTrace();
+                                               LOGGER.error("Error while converting string to an input stream:", ioe);
                                        }
-                                       JSONObject deleteMM = (JSONObject) jsonOb.getJSONObject("deleteMirrorMaker");
+                                       JSONObject deleteMM = jsonOb.getJSONObject("deleteMirrorMaker");
 
                                        JSONObject existMirrorMaker = validateMMExists(ctx, deleteMM.getString("name"));
 
                                }
 
                        } catch (IOException ioe) {
-
+                               LOGGER.error("Error in callDeleteMirrorMaker:", ioe);
                                throw ioe;
                        }
 
                        }
 
                } catch (Exception e) {
-
+                       LOGGER.error("Error in callPubSub", e);
                        throw e;
                }
 
                                                        inStream = IOUtils.toInputStream(listAll.toString(), "UTF-8");
 
                                                } catch (IOException ioe) {
-                                                       ioe.printStackTrace();
+                                                       LOGGER.error("Error while converting string to an input stream:", ioe);
                                                }
                                                JSONObject listMirrorMaker = new JSONObject();
                                                listMirrorMaker = callPubSub(randomStr, ctx, inStream, null, true);
                                }
 
                        } catch (IOException e) {
-
-                               e.printStackTrace();
+                               LOGGER.error("Error in listWhiteList", e);
                        }
                } else {
                        ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_UNAUTHORIZED,
                                                        inStream = IOUtils.toInputStream(listAll.toString(), "UTF-8");
 
                                                } catch (IOException ioe) {
-                                                       ioe.printStackTrace();
+                                                       LOGGER.error("Error while converting string to an input stream:", ioe);
                                                }
                                                String msgFrmSubscribe = mirrorService.subscribe(ctx, topic, consumergroup, consumerid);
                                                // call listAllMirrorMaker
                                                        inStream = IOUtils.toInputStream(listAll.toString(), "UTF-8");
 
                                                } catch (IOException ioe) {
-                                                       ioe.printStackTrace();
+                                                       LOGGER.error("Error while converting string to an input stream:", ioe);
                                                }
                                                // call listAllMirrorMaker
                                                mirrorService.pushEvents(ctx, topic, inStream, null, null);
                                                jsonArrayNamespace = jsonObj.getJSONArray("listMirrorMaker");
                                        }
                                }
+
                                JSONObject finalJasonObj = new JSONObject();
                                JSONArray finalJsonArray = new JSONArray();
 
-                               for (int i = 0; i < jsonArrayNamespace.length(); i++) {
+                               if (jsonArrayNamespace != null) {
+                                       for (int i = 0; i < jsonArrayNamespace.length(); i++) {
 
-                                       JSONObject mmObj = new JSONObject();
-                                       mmObj = jsonArrayNamespace.getJSONObject(i);
-                                       if (mmObj.has("name") && mmName.equals(mmObj.getString("name"))) {
+                                               JSONObject mmObj = new JSONObject();
+                                               mmObj = jsonArrayNamespace.getJSONObject(i);
+                                               if (mmObj.has("name") && mmName.equals(mmObj.getString("name"))) {
 
-                                               finalJsonArray.put(mmObj);
-                                       }
+                                                       finalJsonArray.put(mmObj);
+                                               }
 
+                                       }
                                }
                                finalJasonObj.put("listMirrorMaker", finalJsonArray);
 
                        }
 
                } catch (Exception e) {
-                       e.printStackTrace();
+                       LOGGER.error("Error in callPubSubForWhitelist:", e);
                }
        }
 
                        listAll.put("listAllMirrorMaker", new JSONObject());
 
                } catch (JSONException e) {
-
-                       e.printStackTrace();
+                       LOGGER.error("Error while creating a listAllMirrorMaker Json object:", e);
                }
 
                // set a random number as messageID
                        inStream = IOUtils.toInputStream(listAll.toString(), "UTF-8");
 
                } catch (IOException ioe) {
-                       ioe.printStackTrace();
+                       LOGGER.error("Error while converting string to an input stream:", ioe);
                }
                JSONObject listMirrorMaker = new JSONObject();
                listMirrorMaker = callPubSub(randomStr, ctx, inStream, name, false);
                        return listMirrorMaker;
 
                }
-               listMirrorMaker.put("exists", false);
-               return listMirrorMaker;
 
+               if(null != listMirrorMaker) {
+                       listMirrorMaker.put("exists", false);
+               }
+
+               return listMirrorMaker;
        }
 }