it'd be nice to abstract as much of this logic as possible into elegant, composable helper methods