Last part of TPE exercise 4