dynamically adding options and slight refactoring