fixes bug in error handling code from previous commit