Rewrite some logic so C++11 considers it a boolean context