add more error capturing