Merge pull request #211 from tjmcs/master

Fixes bug in error handling code from previous pull request