Refactored code and added new options