diff --git a/largest_file.sh b/largest_file.sh
index 1a502b24ee27328714a03447f1ce59c251a169c3..42d1c34c71e9f9e959a3a37f178961d53f2940dc 100755
--- a/largest_file.sh
+++ b/largest_file.sh
@@ -5,14 +5,30 @@ if [ $# -ne 1 ];then
     exit 1
 fi
 
-FILES=$(ls -R $1)
+FILES=$(find $1 -type f )
 
-if [ $? -eq 1 ]; then
-    echo "folder not existing"
+if [ $? -ne 0 ]; then
+    echo "folder does not exist"
     exit 1
 fi
 
-if [ "$FILES" = " " ]; then
+if [ "$FILES" = "$1:" ]; then
     echo "folder empty"
     exit 1
 fi
+MAX_SIZE=0
+MAX_FILE=""
+for f in $FILES; do
+    SIZE=$(stat -c %s $f)
+    if [ $SIZE -gt $MAX_SIZE ]; then
+        MAX_SIZE=$SIZE
+        MAX_FILE=$f
+    fi
+done
+
+if [ "$MAX_FILE" = "" ]; then
+    echo "all files are empty"
+fi
+echo "$MAX_FILE : $MAX_SIZE bytes"
+
+