handling errors more nicely