part2 of big refactor
part 3 of big refactor