fixed bug checking error status