Fixed a typo and a logical error.