moving collect to after table flushing