Simplified logic for easier visual code reading.