Added functions to simplify the script
Removed useless cd
Reversed the order of the function arguments