Updated solution to excercise a.