fix $exists + optimize sparql queries