improve cli flag handling