try to improve error capturing