cleaned up some exception handling code