I wrote solution for part 2