fix bug in bag reconstruction