tweak some error handling