Extracting option better

adding support for endpoint via configuration

extract option in a better way