solution to part 1