diff --git a/assets/scripts/playerctl_loader.sh b/assets/scripts/playerctl_loader.sh
index 485a8064c5ea93ee1eae9f34c09806765698f096..9148a02263de410d776661f250c3f2418d7b41ae 100644
--- a/assets/scripts/playerctl_loader.sh
+++ b/assets/scripts/playerctl_loader.sh
@@ -10,8 +10,10 @@ mkdir -p "$res_dir"
 
 function player(){
   if [[ -n "$current_player" ]];then
+    # shellcheck disable=SC2145
     res="$(eval "playerctl --player=$current_player $@ || echo 'ERROR'")" 
   else
+    # shellcheck disable=SC2145
     res="$(eval "playerctl $@ || echo 'ERROR'")"
   fi
   echo "$res"
@@ -22,27 +24,75 @@ function cleanup_and_exit() {
     rm -fv "current.mp3" "bg.png" "cover.jpg" "cover.png"
     ffmpeg -f concat -i concat -c copy "compiled-$((compiled_index + 1)).webm"
     rm -fv "concat"
-    popd
-    ls "$workdir" | grep compiled | xargs -I '{}' mv -v $workdir/'{}' "$res_dir"
+    popd || exit 
+    find "$workdir" -maxdepth 1 -name "compiled*" -print0 | xargs -I '{}' mv -v '{}' "$res_dir"
   fi
   rm -rfv "$workdir"
 }
 
 function read_player(){
   echo "Which player should I use?"
-  printf "Available players:\n$(playerctl -l | sed "s/^/* /")\n"
+  printf "Available players:\n%s\n" "$(playerctl -l | sed "s/^/* /")"
+  # shellcheck disable=SC2162
   read -p '> ' current_player
 }
 
+function render_on_cpu(){
+  background="$1"
+  sound="$2"
+  index="$3"
+  target_adv="$4"
+  ffmpeg -loop 1 -r 3 -i "$background" -i "$sound" -r 25 -i "${target_adv}" \
+    -filter_complex "[0:v]scale=w=1280:h=720:force_original_aspect_ratio=2,crop=1280:720[img]; \
+    [2:v]setpts=10*PTS[adv]; \
+    [adv]loop[ladv]; \
+    [img][ladv]overlay=enable='gt(mod(t, 40), 30)'[rv]" \
+    -map "[rv]" \
+    -map 1:a \
+    -framerate 30 -g 60 \
+    -c:v vp8 -pix_fmt yuv420p -movflags +faststart \
+    -vb 4000k \
+    -f webm \
+    -c:a libopus \
+    -err_detect ignore_err \
+    -shortest -strict -2 -y \
+    "${index}.webm"
+}
+
+function render_on_gpu(){
+  background="$1"
+  sound="$2"
+  index="$3"
+  target_adv="$4"
+  ffmpeg -loop 1 -init_hw_device cuda=cuda:0 \
+    -hwaccel nvdec \
+    -vsync 1 -async 1 \
+    -r 5 -i "$background" -i "$sound" -r 25 -i "${target_adv}" \
+    -filter_complex "[0:v]scale=w=1280:h=720:force_original_aspect_ratio=2,crop=1280:720[img]; \
+    [2:v]setpts=10*PTS[adv]; \
+    [adv]loop[ladv]; \
+    [img][ladv]overlay=enable='gt(mod(t, 40), 30)'[rv]" \
+    -map "[rv]" \
+    -map 1:a \
+    -framerate 30 -g 60 \
+    -c:v vp8 -pix_fmt yuv420p -movflags +faststart \
+    -vb 4000k \
+    -f webm \
+    -c:a libopus \
+    -err_detect ignore_err \
+    -shortest -strict -2 -y \
+    "${index}.webm"
+}
+
 trap "cleanup_and_exit" EXIT
 
-if [[ !( $(playerctl -l | wc -l) -eq 1) ]];then
+if [[ ! ($(playerctl -l | wc -l) -eq 1) ]];then
   read_player
 else
   current_player="$(playerctl -l)"
 fi
 
-if [[ !( $(player status) ) ]]; then
+if [[ ! ($(player status) ) ]]; then
   echo "Can't find any player"
   exit 1
 fi
@@ -52,13 +102,13 @@ if [[ $(player status) != "Playing" ]]; then
 fi
 
 if [[ -e "${res_dir}" ]];then
-  compiled_index="$(ls "$res_dir" | grep compiled | sort --numeric-sort | tail -n 1 | cut -d '.' -f1 | cut -d '-' -f2)"
+  compiled_index="$(find "$res_dir" -name "compiled*" -print0 | sort --numeric-sort | tail -n 1 | cut -d '.' -f1 | cut -d '-' -f2)"
 else
   compiled_index="-1"
 fi
 index="0"
 
-pushd "$workdir"
+pushd "$workdir" || exit 1
 
 job_started=1
 
@@ -89,22 +139,14 @@ while [[ "$(player status)" = "Playing" ]];do
 
   target_adv="$(find "$ads_dir" -type f | shuf -n 1)"
   echo "Rendering ${index}"
-  ffpb -loop 1 -r 3 -i bg.png -i current.mp3 -r 25 -i "${target_adv}" \
-    -filter_complex "[0:v]scale=w=1280:h=720:force_original_aspect_ratio=2,crop=1280:720[img]; \
-    [2:v]setpts=10*PTS[adv]; \
-    [adv]loop[ladv]; \
-    [img][ladv]overlay=enable='gt(mod(t, 40), 30)'[rv]" \
-    -map "[rv]" \
-    -map 1:a \
-    -framerate 30 -g 60 \
-    -c:v vp8 -pix_fmt yuv420p -movflags +faststart \
-    -vb 4000k \
-    -f webm \
-    -c:a libopus \
-    -err_detect ignore_err \
-    -shortest -strict -2 -y \
-    "${index}.webm"
-  
+  if ! command -v nvcc &> /dev/null; then
+    echo "Cuda was not found. Rendering on cpu."
+    echo "Lowering fps..."
+    render_on_cpu "bg.png" "current.mp3" "${index}" "${target_adv}"
+  else
+    echo "Cuda was found. Hardware acceleration enabled."
+    render_on_gpu "bg.png" "current.mp3" "${index}" "${target_adv}"
+  fi
   echo "file '${index}.webm'" >> concat
 
   index=$((index + 1))