Simplified the unnecessarily complicated if block.