split query code into separate files