Helper function to parse options