finished problem 1 and refactored based on overview