diff --git a/lib/api.dart b/lib/api.dart
index 221c5c113b134c0a80caa23dac7791413e39547c..0221b35beac828ae0edcf2762cb6fc4cd0d563e4 100644
--- a/lib/api.dart
+++ b/lib/api.dart
@@ -4,23 +4,11 @@ import 'package:gql_dio_link/gql_dio_link.dart';
 import 'package:gql_exec/gql_exec.dart';
 import "package:gql_link/gql_link.dart";
 
+// Configure node
 const graphqlEndpoint = "https://g1.librelois.fr/gva";
 
-const QcurrentUD = """{
-    currentUd {
-      amount
-      base
-}
-}""";
-
-Future getBalance(String pubkey) async {
-  var qBalance = """{
-    balance(script: "$pubkey") {
-      amount
-      base
-    }
-  }""";
-
+// Build query
+Future buildQ(query) async {
   final client = dio.Dio();
   final Link link = DioLink(
     graphqlEndpoint,
@@ -29,17 +17,45 @@ Future getBalance(String pubkey) async {
 
   final res = await link
       .request(Request(
-        operation: Operation(document: gqlLang.parseString(qBalance)),
+        operation: Operation(document: gqlLang.parseString(query)),
       ))
       .first;
 
-  final balance = res.data["balance"]["amount"] / 100;
-  return balance;
+  return res;
+}
+
+/* Requests functions */
+
+// Get current UD
+Future getUD() async {
+  const query = """{
+      currentUd {
+        amount
+        base
+  }
+  }""";
+
+  final result = await buildQ(query);
+  return result.data["currentUd"]["amount"];
+}
+
+// Get balance
+Future getBalance(String pubkey) async {
+  var query = """{
+    balance(script: "$pubkey") {
+      amount
+      base
+    }
+  }""";
+
+  final result = await buildQ(query);
+  return result.data["balance"]["amount"] / 100;
 }
 
+// Get history
 Future getHistory(String pubkey) async {
   print(pubkey);
-  var qHistory = """{
+  var query = """{
         transactionsHistory(pubkey: "$pubkey") {
             received {
                 writtenTime
@@ -50,18 +66,9 @@ Future getHistory(String pubkey) async {
         }
     }""";
 
-  final client = dio.Dio();
-  final Link link = DioLink(
-    graphqlEndpoint,
-    client: client,
-  );
-
-  final res = await link
-      .request(Request(
-        operation: Operation(document: gqlLang.parseString(qHistory)),
-      ))
-      .first;
+  final res = await buildQ(query);
 
+  // Parse history
   var result = res.data["transactionsHistory"]["received"];
   String outPubkey;
   for (var bloc in result) {
@@ -70,6 +77,5 @@ Future getHistory(String pubkey) async {
     print(outPubkey);
   }
 
-  final history = outPubkey;
-  return history;
+  return outPubkey;
 }
diff --git a/lib/data/currentUD.dart b/lib/data/currentUD.dart
deleted file mode 100644
index 11f6683e232a835c4ea925987787a87129a7d407..0000000000000000000000000000000000000000
--- a/lib/data/currentUD.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-class TodoFetch {
-  static String fetchAll = """
-    query {
-      currentUd {
-        amount,
-        base
-      }
-    }
-  """;
-}
diff --git a/lib/main.dart b/lib/main.dart
index 95c53126c443eb96629ab977a655ba6d295b36b8..ae9db6b1d04c8a3a9be79383eac5135287458e4b 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -18,13 +18,13 @@ class MyApp extends StatefulWidget {
 
 class _MyAppState extends State<MyApp> {
   Uint8List bytes = Uint8List(0);
-  TextEditingController _outputController;
+  TextEditingController _outputPubkey;
   TextEditingController _outputAmount;
 
   @override
   initState() {
     super.initState();
-    this._outputController = new TextEditingController();
+    this._outputPubkey = new TextEditingController();
     this._outputAmount = new TextEditingController();
   }
 
@@ -43,7 +43,7 @@ class _MyAppState extends State<MyApp> {
                       children: <Widget>[
                         SizedBox(height: 20),
                         TextField(
-                          controller: this._outputController,
+                          controller: this._outputPubkey,
                           maxLines: 2,
                           decoration: InputDecoration(
                             prefixIcon: Icon(Icons.wrap_text),
@@ -120,14 +120,13 @@ class _MyAppState extends State<MyApp> {
       print('nothing return.');
     } else {
       print("Debug: " + barcode);
-      this._outputController.text = "";
+      this._outputPubkey.text = "";
       this._outputAmount.text = "";
-      var myAmount = await getHistory(barcode.toString());
-      this._outputController.text = barcode;
-      print(myAmount.toString());
-      this._outputAmount.text = myAmount.toString();
-
-      // _getAmount(barcode);
+      // final udValue = await getUD();
+      final myBalance = await getBalance(barcode.toString());
+      this._outputPubkey.text = barcode;
+      print(myBalance.toString());
+      this._outputAmount.text = myBalance.toString();
     }
   }