Refactored code and added different control types