huge REFACTOR