bug 1138: Reorder if clauses for better readability