factorisation of code for tags in sparql query