reduce error checking boiler-plate with check macro