Solutiond for 2nd assignment