Finished Question2 code