more major refactoring, because its fun