refactored options parsing