Simple rank queries working (edge cases failing)