Added dump of vars so I could see what is going into the query and what is going wrong.