replaced all ES queries by conditions