exercise 3 of ML done