restructured demo 1 code