applied patch for pull request 932 from rowanhill