also this whole block is ripe for DRY'ing up a bit