solved task number 5, except for the final refactoring