refactored Problem 1
refactored Problem 2
refactored Problem 3
refactored Problem 4