fork of https://drupal.org/sandbox/bobbydank/2045997