half-refactored ugh...