implemented new features and refactored design