Fixed logic in IF statements.