added a new macro to pull out some more common logic