fixed error check