partial refactor part 2