fixing bug: return the query promise