refactoring a bunch of things