fixes bug in error handling code from previous commit
Merge pull request #211 from tjmcs/master

Fixes bug in error handling code from previous pull request