major refactoring, messy right now