implemented task 5 as best as possible