Fix minor error in logic