Fix for creating queries