fixed bug in reconstruct_loop