exercise 5 corrected and 6 prettyfied