Refactored command line argument handling