refactor codes for option selection