Adds more error catching