added some error corrections