You have a function defined in your Bash script. You call the function you created. But you get "command not found". What should you do?
The Bash script is parsed from the top of the file to the bottom of the file. You cannot invoke the function before it has been defined. Place the function above the line where it is called. The function should probably go near the top despite the lack of readability.