Simplified some if constructs