reduce 2 queries to one within the new functions