Added error catching.