Consider simplifying to if blocks for readability.