Reowrk the logic a bit.