fixing query generation for various types