fixed bug in correct error and z detection