added unflatten tool in the script