fixed error in query