fixed error check bug