backport code from CHEF-867