fixing ordering on query