Made the script as a function that accepts argvs