Fixed ordering logic.