refactoring and adding options