improved option parsing