refactored a ton of shit