capture errors more cleanly