fix referential query