Fix logic and typo.