Refactored option parsing