Pull query out of lirr module