Fixed a typo and a logic flaw X2