added conditions on query