appended from gist