See code in the attached pictures. This is part 1