use gateway for quering