solved to problem 5, working on problem 6, tests to be refactored