wrong value used in if check