reconstruct function