diff --git a/install_wolf.sh b/install_wolf.sh
index 00af512888be3decfb49a7866a33ee5c67e85b9b..0d94c31236f363bcada7e0ac75113e606392e60f 100755
--- a/install_wolf.sh
+++ b/install_wolf.sh
@@ -1,5 +1,20 @@
 #!/bin/bash
 
+## FUNCTIONS
+func_make_install () {
+   if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
+      make install
+   else
+      sudo make install
+   fi
+}
+
+func_echo () {
+	if [ $VERBOSE == "true" ]; then
+	   echo "$1"
+	fi
+}
+
 # verbose
 VERBOSE="true"
 while getopts "he" option; do
@@ -11,27 +26,23 @@ while getopts "he" option; do
 done
 
 CORES=$(nproc)
-if [ $VERBOSE == "true" ]; then
-   echo "The number of available cores on this machine is $CORES"
-fi
+func_echo "The number of available cores on this machine is $CORES"
 
 RUN_PATH=$PWD
 
 # UBUNTU
-apt install -y lsb-core
+if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
+   apt install -y lsb-core
+else
+   sudo apt install -y lsb-core
+fi
 UBUNTU_DISTRO=$(lsb_release -rs);
 if [ $UBUNTU_DISTRO == "16.04" ]; then
-   if [ $VERBOSE == "true" ]; then
-      echo "Ubuntu 16.04 - OK"
-   fi
+   func_echo "Ubuntu 16.04 - OK"
 elif [ $UBUNTU_DISTRO == "18.04" ]; then
-   if [ $VERBOSE == "true" ]; then
-      echo "Ubuntu 18.04 - OK"
-   fi
+   func_echoo "Ubuntu 18.04 - OK"
 elif [ $UBUNTU_DISTRO == "20.04" ]; then
-   if [ $VERBOSE == "true" ]; then
-      echo "Ubuntu 20.04 - OK"
-   fi
+   func_echo "Ubuntu 20.04 - OK"
 else
    echo "Non-supported Ubuntu version: $UBUNTU_DISTRO"
    exit 1
@@ -39,28 +50,25 @@ fi
 
 
 # WOLF DEPENDENCIES #####################################################
-if [ $VERBOSE == "true" ]; then
-   echo "You are in folder $PWD"
-fi
+func_echo "You are in folder $PWD"
 echo "Enter path for dependencies (either /global/path or relative/path):"
 read DEPS_PATH
 cd $DEPS_PATH
 DEPS_PATH=$PWD
-if [ $VERBOSE == "true" ]; then
-   echo "path dependencies: $DEPS_PATH"
-fi
+func_echo "path dependencies: $DEPS_PATH"
 
-if [ $VERBOSE == "true" ]; then
-   echo "Installing dependencies via apt install..."
+func_echo "Installing dependencies via apt install..."
+
+if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
+   apt install -y git wget unzip dh-autoreconf cmake build-essential libgoogle-glog-dev libgflags-dev libatlas-base-dev libsuitesparse-dev git libboost-all-dev libyaml-cpp-dev wget unzip
+else
+   sudo apt install -y git wget unzip dh-autoreconf cmake build-essential libgoogle-glog-dev libgflags-dev libatlas-base-dev libsuitesparse-dev git libboost-all-dev libyaml-cpp-dev wget unzip
 fi
-apt install -y git wget unzip dh-autoreconf cmake build-essential libgoogle-glog-dev libgflags-dev libatlas-base-dev libsuitesparse-dev git libboost-all-dev libyaml-cpp-dev wget unzip
 
 # Eigen
 # Ubuntu 16.04 - Eigen 3.3.7 required
 if [ $UBUNTU_DISTRO == "16.04" ]; then
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing Eigen 3.3.7 via source..."
-   fi
+   func_echo "Installing Eigen 3.3.7 via source..."
    # todo check if installed, check version, check 
    wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip
    unzip eigen-3.3.7.zip
@@ -69,18 +77,14 @@ if [ $UBUNTU_DISTRO == "16.04" ]; then
    mkdir build
    cd build
    cmake ..
-   make install
+   func_make_install
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing Eigen 3 via apt install"
-   fi
+   func_echo "Installing Eigen 3 via apt install"
    apt install -y libeigen3-dev
 fi 
 
 # ceres
-if [ $VERBOSE == "true" ]; then
-   echo "Installing ceres 2.0 via source..."
-fi
+func_echo "Installing ceres 2.0 via source..."
 cd $DEPS_PATH
 git clone https://ceres-solver.googlesource.com/ceres-solver
 cd ceres-solver
@@ -90,12 +94,10 @@ mkdir -p build && cd build
 cmake -DCMAKE_BUILD_TYPE=Release ..
 make -j$CORES
 make test
-make install
+func_make_install
 
 # spdlog
-if [ $VERBOSE == "true" ]; then
-   echo "Installing spdlog 0.17 via source..."
-fi
+func_echo "Installing spdlog 0.17 via source..."
 cd $DEPS_PATH
 git clone https://github.com/gabime/spdlog.git
 cd spdlog
@@ -104,50 +106,37 @@ git pull
 mkdir -p build && cd build
 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fPIC" ..
 make -j$CORES
-make install
+func_make_install
 
 
 # WOLF #####################################################
 cd $RUN_PATH
-if [ $VERBOSE == "true" ]; then
-   echo "You are in folder $PWD"
-fi
+func_echo "You are in folder $PWD"
 echo "Enter path for wolf folder (either /global/path or relative/path):"
 read WOLF_PATH
 cd $WOLF_PATH
 mkdir wolf
 cd wolf
 WOLF_PATH=$PWD
-if [ $VERBOSE == "true" ]; then
-   echo "wolf folder path: $PWD/wolf"
-fi
+func_echo "wolf folder path: $PWD/wolf"
 
 
 # CORE -----------------------------------------------------
-if [ $VERBOSE == "true" ]; then
-   echo "Cloning wolf core..."
-fi
+func_echo "Cloning wolf core..."
 cd $WOLF_PATH
-git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/wolf.git
+git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/wolf.git
 cd wolf
 git pull
 
-if [ $VERBOSE == "true" ]; then
-   echo "Compiling wolf core..."
-fi
+func_echo "Compiling wolf core..."
 mkdir -p build && cd build
 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEMOS=ON -DBUILD_TESTS=ON ..
-cd build
 make -j$CORES
 
-if [ $VERBOSE == "true" ]; then
-   echo "Installing wolf core..."
-fi
-make install
+func_echo "Installing wolf core..."
+func_make_install
 
-if [ $VERBOSE == "true" ]; then
-   echo "Testing wolf core..."
-fi
+func_echo "Testing wolf core..."
 ctest -j$CORES
 
 
@@ -156,35 +145,24 @@ echo "Do you want to download and install plugin imu? (y/n)"
 read INSTALL_IMU
 if [ $INSTALL_IMU == "y" ]; then
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Cloning plugin imu..."
-   fi
+   func_echo "Cloning plugin imu..."
    cd $WOLF_PATH
-   git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/imu.git
+   git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/imu.git
    cd imu
    git pull
    
-   if [ $VERBOSE == "true" ]; then
-      echo "Compiling plugin imu..."
-   fi
+   func_echo "Compiling plugin imu..."
    mkdir -p build && cd build
    cmake .. -DCMAKE_BUILD_TYPW=Release
-   cd build
    make -j$CORES
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin imu..."
-   fi
-   make install
+   func_echo "Installing plugin imu..."
+   func_make_install
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Testing plugin imu..."
-   fi
+   func_echo "Testing plugin imu..."
    ctest -j$CORES
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Skipping plugin imu."
-   fi
+   func_echo "Skipping plugin imu."
 fi
 
 # GNSS --------------------------------------------------
@@ -192,9 +170,7 @@ echo "Do you want to download and install plugin gnss? (y/n)"
 read INSTALL_GNSS
 if [ $INSTALL_GNSS == "y" ]; then
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin gnss dependencies..."
-   fi
+   func_echo "Installing plugin gnss dependencies..."
    cd $DEPS_PATH
    git clone https://gitlab.iri.upc.edu/mobile_robotics/gauss_project/gnss_utils.git
    cd gnss_utils
@@ -203,37 +179,26 @@ if [ $INSTALL_GNSS == "y" ]; then
    cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEMOS=ON -DBUILD_TESTS=ON ..
    make -j$CORES
    ctest -j$CORES
-   make install
+   func_make_install
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Cloning plugin gnss..."
-   fi
+   func_echo "Cloning plugin gnss..."
    cd $WOLF_PATH
-   git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/gnss.git
+   git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/gnss.git
    cd gnss
    git pull
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Compiling plugin gnss..."
-   fi
+   func_echo "Compiling plugin gnss..."
    mkdir -p build && cd build
    cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEMOS=ON -DBUILD_TESTS=ON ..
-   cd build
    make -j$CORES
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin gnss..."
-   fi
-   make install
+   func_echo "Installing plugin gnss..."
+   func_make_install
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Testing plugin gnss..."
-   fi
+   func_echo "Testing plugin gnss..."
    ctest -j$CORES
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Skipping plugin gnss."
-   fi
+   func_echo "Skipping plugin gnss."
 fi
 
 
@@ -242,9 +207,7 @@ echo "Do you want to download and install plugin laser? (y/n)"
 read INSTALL_LASER
 if [ $INSTALL_LASER == "y" ]; then
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin laser dependencies..."
-   fi
+   func_echo "Installing plugin laser dependencies..."
 
    # CSM
    echo "Do you want to install CSM to enable ICP processors? (y/n)"
@@ -256,11 +219,9 @@ if [ $INSTALL_LASER == "y" ]; then
       mkdir -p build && cd build
       cmake -DCMAKE_BUILD_TYPE=Release ..
       make -j$CORES
-      make install
+      func_make_install
    else 
-      if [ $VERBOSE == "true" ]; then
-         echo "Skipping CSM."
-      fi
+      func_echo "Skipping CSM."
    fi
 
    # FALKO
@@ -273,17 +234,13 @@ if [ $INSTALL_LASER == "y" ]; then
       mkdir -p build && cd build
       cmake -DCMAKE_BUILD_TYPE=Release ..
       make -j$CORES
-      make install
+      func_make_install
    else 
-      if [ $VERBOSE == "true" ]; then
-         echo "Skipping Falko."
-      fi
+      func_echo "Skipping Falko."
    fi
 
    # LASER_SCAN_UTILS
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing laser_scan_utils (required)..."
-   fi
+   func_echo "Installing laser_scan_utils (required)..."
    cd $DEPS_PATH
    ldconfig
    git clone https://gitlab.iri.upc.edu/labrobotica/algorithms/laser_scan_utils.git
@@ -292,40 +249,29 @@ if [ $INSTALL_LASER == "y" ]; then
    cmake -DCMAKE_BUILD_TYPE=Release ..
    make -j$CORES
    ctest -j$CORES
-   make install
+   func_make_install
 
    # PLUGIN
-   if [ $VERBOSE == "true" ]; then
-      echo "Cloning plugin laser..."
-   fi
+   func_echo "Cloning plugin laser..."
    cd $WOLF_PATH
    ldconfig
-   git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/laser.git
+   git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/laser.git
    cd laser
    git pull
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Compiling plugin laser..."
-   fi
+   func_echo "Compiling plugin laser..."
    mkdir -p build && cd build
    cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEMOS=ON -DBUILD_TESTS=ON ..
-   cd build
    make -j$CORES
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin laser..."
-   fi
-   make install
+   func_echo "Installing plugin laser..."
+   func_make_install
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Testing plugin laser..."
-   fi
+   func_echo "Testing plugin laser..."
    ldconfig
    ctest -j$CORES
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Skipping plugin laser."
-   fi
+   func_echo "Skipping plugin laser."
 fi
 
 # VISION --------------------------------------------------
@@ -333,55 +279,42 @@ echo "Do you want to download and install plugin vision (requires to install ope
 read INSTALL_VISION
 if [ $INSTALL_VISION == "y" ]; then
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin vision dependencies..."
-   fi
+   func_echo "Installing plugin vision dependencies..."
    cd $DEPS_PATH
 
    #install opencv
    wget https://github.com/opencv/opencv/archive/3.3.0.zip -O temp.zip
-	unzip temp.zip
-	rm temp.zip
-	cd opencv-3.3.0
-	git clone https://github.com/opencv/opencv_contrib.git
-	cd opencv_contrib
-	git checkout 3.3.0
-	cd ..
-	mkdir build
-	cd build
-	cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_CXX_FLAGS="-fPIC -std=c++14" -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
-	make -j8
-	make install
-
-   if [ $VERBOSE == "true" ]; then
-      echo "Cloning plugin vision..."
-   fi
+   unzip temp.zip
+   rm temp.zip
+   cd opencv-3.3.0
+   git clone https://github.com/opencv/opencv_contrib.git
+   cd opencv_contrib
+   git checkout 3.3.0
+   cd ..
+   mkdir build
+   cd build
+   cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_CXX_FLAGS="-fPIC -std=c++14" -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
+   make -j$CORES
+   func_make_install
+
+   func_echo "Cloning plugin vision..."
    cd $WOLF_PATH
-   git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/vision.git
+   git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/vision.git
    cd vision
    git pull
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Compiling plugin vision..."
-   fi
+   func_echo "Compiling plugin vision..."
    mkdir -p build && cd build
    cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEMOS=ON -DBUILD_TESTS=ON ..
-   cd build
    make -j$CORES
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Installing plugin vision..."
-   fi
-   make install
+   func_echo "Installing plugin vision..."
+   func_make_install
 
-   if [ $VERBOSE == "true" ]; then
-      echo "Testing plugin vision..."
-   fi
+   func_echo "Testing plugin vision..."
    ctest -j$CORES
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Skipping plugin vision."
-   fi
+   func_echo "Skipping plugin vision."
 fi
 
 # APRILTAG --------------------------------------------------
@@ -390,9 +323,7 @@ if [ $INSTALL_VISION == "y" ]; then
    read INSTALL_APRILTAG
    if [ $INSTALL_APRILTAG == "y" ]; then
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Installing plugin apriltag dependencies..."
-      fi
+      func_echo "Installing plugin apriltag dependencies..."
       cd $DEPS_PATH
       git clone https://github.com/AprilRobotics/apriltag apriltaglib
       cd apriltaglib
@@ -400,42 +331,29 @@ if [ $INSTALL_VISION == "y" ]; then
       cmake -DCMAKE_BUILD_TYPE=Release ..
       make -j$CORES
       ctest -j$CORES
-      make install
+      func_make_install
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Cloning plugin apriltag..."
-      fi
+      func_echo "Cloning plugin apriltag..."
       cd $WOLF_PATH
-      git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/apriltag.git
+      git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/apriltag.git
       cd apriltag
       git pull
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Compiling plugin apriltag..."
-      fi
+      func_echo "Compiling plugin apriltag..."
       mkdir -p build && cd build
       cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEMOS=ON -DBUILD_TESTS=ON ..
-      cd build
       make -j$CORES
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Installing plugin apriltag..."
-      fi
-      make install
+      func_echo "Installing plugin apriltag..."
+      func_make_install
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Testing plugin apriltag..."
-      fi
+      func_echo "Testing plugin apriltag..."
       ctest -j$CORES
    else
-      if [ $VERBOSE == "true" ]; then
-         echo "Skipping plugin apriltag."
-      fi
+      func_echo "Skipping plugin apriltag."
    fi
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Skipping plugin apriltag since plugin vision was not installed."
-   fi
+   func_echo "Skipping plugin apriltag since plugin vision was not installed."
 fi
 
 # BODYDYNAMICS --------------------------------------------------
@@ -444,38 +362,27 @@ if [ $INSTALL_IMU == "y" ]; then
    read INSTALL_BD
    if [ $INSTALL_BD == "y" ]; then
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Cloning plugin bodydynamics..."
-      fi
+      func_echo "Cloning plugin bodydynamics..."
       cd $WOLF_PATH
-      git clone https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/bodydynamics.git
+      git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/bodydynamics.git
       cd bodydynamics
       git pull
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Compiling plugin bodydynamics..."
-      fi
+      func_echo "Compiling plugin bodydynamics..."
       mkdir -p build && cd build
       cmake .. -DCMAKE_BUILD_TYPW=Release
-      cd build
       make -j$CORES
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Installing plugin bodydynamics..."
-      fi
-      make install
+      func_echo "Installing plugin bodydynamics..."
+      func_make_install
 
-      if [ $VERBOSE == "true" ]; then
-         echo "Testing plugin bodydynamics..."
-      fi
+      func_echo "Testing plugin bodydynamics..."
       ctest -j$CORES
    else
-      if [ $VERBOSE == "true" ]; then
-         echo "Skipping plugin bodydynamics."
-      fi
+      func_echo "Skipping plugin bodydynamics."
    fi
 else
-   if [ $VERBOSE == "true" ]; then
-      echo "Skipping plugin bodydynamics since plugin imu was not installed."
-   fi
+   func_echo "Skipping plugin bodydynamics since plugin imu was not installed."
 fi
+
+func_echo "Done! Enjoy!"
\ No newline at end of file