refactor retrieve_rows to take the table, so we can get other data out of it