damn, huge refactor