Reordered ES queries to improve performance