moved in here from gist

moved in here from gist: https://gist.github.com/mbohun/bdbef54d89f3c4403ee8