more error catching to improve stability