Added error catching