improved command line logic