Simplified logic a bit.