better catching of errors