code from part1