Added code to answer Q1