loosely following advice from
http://stackoverflow.com/a/17189535/1739415