small fix and refactoring
the solution of the problem 10