stripped down version of my original work at draber/jig