move all the cross table queries to the last