Improves error catching