Don't duplicate codes to sort queries