bug fixed for non-zero detection