diff --git a/manage_proj_badge.py b/manage_proj_badge.py
index 052c2b2d67c73d98704df580683efd36c18eaff1..a97cf273bee17c0815d87e67a0f015ff40c819a6 100644
--- a/manage_proj_badge.py
+++ b/manage_proj_badge.py
@@ -120,10 +120,11 @@ def get_badges():
     https://gitlabhq.gblabs.co.uk/api/v4/projects/r-and-d%2FMiddleman/badges  2>/dev/null
     :return:
     """
-    curl_get = subprocess.Popen([
+    curl_cmd = [
         'curl', '--request', 'GET', '--header', "PRIVATE-TOKEN: {}".format(TOKEN),
         '{api}/projects/{proj_id}/badges'.format(api=CI_API_V4_URL, proj_id=CI_PROJECT_ID)
-    ], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
+    ]
+    curl_get = subprocess.Popen(curl_cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
     curl_get.wait(timeout=10)
     o = curl_get.stdout.readlines()
     if o:
@@ -289,7 +290,10 @@ def remove_badge(badge_id):
     ]
     print(curl_cmd)
     curl_delete = subprocess.Popen(curl_cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
-    curl_delete.wait(timeout=5)
+    try:
+        curl_delete.wait(timeout=15)
+    except subprocess.TimeoutExpired:
+        return []
     o = curl_delete.stdout.readlines()
     if o:
         res = json.loads(o[0].decode())
@@ -319,7 +323,7 @@ if __name__ == "__main__":
     parser.add_argument("refname", default=None,
                         help="The branch or tag name for which project is built, "
                              "which in CI could be access as env variable $CI_COMMIT_REF_NAME ")
-    parser.add_argument("-api", "--api_url", default="https://gitlabhq.gblabs.co.uk/api/v4/")
+    parser.add_argument("-api", "--api_url", default="https://gitlabhq.gblabs.co.uk/api/v4")
     parser.add_argument("--action", default="cleanup",
                         help="""
                         cleanup: Perform removal of duplicate badges which where added by mistake
@@ -341,4 +345,5 @@ if __name__ == "__main__":
             remove_duplicates_custom(get_badges(), pargs.args.split(",")[0])
         elif pargs.action == "update":
             update_badge(pargs.projurl, pargs.refname, pargs.args.split(","))
+            remove_duplicates_custom(get_badges(), pargs.args.split(",")[0])
     exit(0)