Get rid of another hoisted function in query