added some error logging