refactored and optimized how options are generated.