code overhaul to allow writing big table for sebastian