diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c
index ec34b3b0c9598db3b7847c67a46226a077a666f8..1a5fbf36598f2c9aa7bc9434ca0fe497e015dbd6 100644
--- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c
+++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c
@@ -32,32 +32,37 @@ GEN_TYPE_int lrf_read() {
     if (uart_filestream == -1)
         return -1;
 
-    // free buffer
+    //empty buffer
     uart_flush();
 
+    //initialize arrays
+    int i;
     char bytes[6];
+    for (i = 0; i < 6; i++) {
+        bytes[i] = 0;
+    }
     int n_read = 0;
 
-    char value[3];
-    int n = 0;
-
-    int i;
+    char value[4];
+    for (i = 0; i < 4; i++) {
+        value[i] = 0;
+    }
 
+    int n = 0;
     int d;
 
-    // looks like a blocking call and actually is but is always very fast
-    // since it only has to read the queue
+    //receive values
     while (1) {
-        n_read = uart_receive(&bytes, 6, 0);
+        n_read = uart_receive(bytes, 6, 0);
+
+        if(n_read <= 0)
+            return -1;
 
         for (i = 0; i < n_read; i++) {
             if (bytes[i] != 0xd && bytes[i] != 0xa) {
                 value[n++] = bytes[i];
             } else if (atoi(value) != 0) {
                 d = atoi(value);
-                for (i = n; i < 3; i++) {
-                    value[i] = 0;
-                }
                 return d;
             }
         }