big ass refactor