add Dan's unfolding code