refactored the hell out of it