consolidated if block