refactor; change part 2 code