Refactored the shit out of it