damn big refactoring