added some error tracking