Solves 6-10, some refactoring in main class