fix to error in query creation