closes #1463 Thanks to Shawn Landden for the original pull request. This commit is based on that code.