Simplified some logic.