since constraints seems it's own beast, maybe move the constraint code out into a helper to keep the rest reading easily.