beginning work of conditional query