big refactor - part 2