This should hopefully fix the issue with the query being nil.