refactored and completed exercises