Split queries to fix dependency