updating to better handle errors