code generation fixed. works for initial test case
minor changes, demo scope added