Added some error logging