Completed ex1/ex2 of assignment 5