Moved most of the command line logic to the shell script