rank window logic