Updated in response to comments from @hunner