solution problem 5
 solution for problem 4 + tests