Added answer to the second part of the problem