wrote function to fill table with query data