Fix compiler warning. Re-order if-expression for performance reasons