part of http://drupal.org/node/1921418