Changed the logic a bit.