avoid multiple calls to query