diff --git a/common.c b/common.c
index 003139e7539cd7245d208d3e06d237ba6f69009f..bcba1341ec00e8dc995cdb452826e2fd8b538b1a 100644
--- a/common.c
+++ b/common.c
@@ -49,7 +49,7 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
 	return bb;
 }
 
-void set_debug(int debug_arg)
+void check_debug(void)
 {
-	debug = debug_arg;
+	printf("debug: %d\n", debug);
 }
\ No newline at end of file
diff --git a/common.h b/common.h
index 00bcf59f729d757d7213330dec94b81ddae38015..d99131c4634c25d0ecd942ae68b6f8432b98abda 100644
--- a/common.h
+++ b/common.h
@@ -5,7 +5,6 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <unistd.h>
-#include <getopt.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -20,7 +19,7 @@
 #include <libubox/blobmsg.h>
 #include <libubus.h>
 
-int debug;
+extern int debug;
 
 #define debug_print(...)                  \
 	do                                    \
@@ -58,5 +57,5 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
  */
 struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb);
 
-void set_debug(int debug_arg);
+void check_debug(void);
 #endif
diff --git a/dongle.c b/dongle.c
index a98765541a58b10d82dd0e371cb80a8c5f187306..b3e709106d7e3d06419e719b24a68b34b675d80e 100644
--- a/dongle.c
+++ b/dongle.c
@@ -1,3 +1,5 @@
+#include <getopt.h>
+
 #include "common.h"
 #include "dongle_apn.h"
 #include "dongle_pin.h"
@@ -15,30 +17,26 @@ int parse_args(int argc, char **argv)
 {
 	char ch;
 
-	printf("hallå1\n");
-	while ((ch = getopt_long(argc, argv, ":d:", long_options, NULL)) != -1) {
-	int debug_arg;
-		printf("hallå2\n");
+	while ((ch = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
 		switch (ch) {
-		case 'd':
-			debug_arg = atoi(optarg);
-			if (debug_arg > 1 || debug_arg < 0) {
-				debug_print("%s: option '-%c' is invalid.\n", argv[0], optopt);
+			case 'd':
+				debug = atoi(optarg);
+				if (debug > 1 || debug < 0) {
+					printf("%s: option '-%c' is invalid.\n", argv[0], optopt); //cant exactly do debug print in here...
+					goto fail;
+				}
+				break;
+			case ':':
+				debug_print(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt);
+				goto fail;
+				break;
+			case '?':
+				debug_print(stderr, "%s: option '-%c' is invalid: ignored\n", argv[0], optopt);
 				goto fail;
-			}
-			printf("hallå3\n");
-			//set_debug(debug_arg);
-			break;
-		case ':':
-			debug_print(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt);
-			goto fail;
-			break;
-		case '?':
-			debug_print(stderr, "%s: option '-%c' is invalid: ignored\n", argv[0], optopt);
-			goto fail;
-			break;
+				break;
 		}
 	}
+
 	return 0;
 fail:
 	return -1;