fixed ordering logic