Adding an error catching part.