begin big refactor