Solved Problem 6, refactored some others