Added some janky logging code to handle errors