diff --git a/video_prediction_tools/HPC_scripts/preprocess_data_era5_step1_template.sh b/video_prediction_tools/HPC_scripts/preprocess_data_era5_step1_template.sh
index 5c5392ee32bcd53948d99dc46cb5e3074751136b..afee9a5742a98c191ebbd9a4f130c18905e99d94 100644
--- a/video_prediction_tools/HPC_scripts/preprocess_data_era5_step1_template.sh
+++ b/video_prediction_tools/HPC_scripts/preprocess_data_era5_step1_template.sh
@@ -41,8 +41,8 @@ declare -a years=(
                  "2017"
                   )
 
-max_year=`echo "${years[*]}" | sort -nr | head -n1`
-min_year=`echo "${years[*]}" | sort -nr | tail -n1`
+max_year=$( printf "%d\n" "${years[@]}" | sort -n | tail -1 )
+min_year=$( printf "%d\n" "${years[@]}" | sort -nr | tail -1 )
 # set some paths
 # note, that destination_dir is used during runtime to set a proper experiment directory
 exp_id=xxx                                          # experiment identifier is set by 'generate_workflow_runscripts.sh'