moved xquery code to separate files