Finished and debugged second question.