reorder some ifs