working query display function