this code block was sticking way out, usage detailed on gist anyway