Would love to find a clearer/more elegant way to do this, though...