Extract option parsing to new function