better error handling code styling