fixed bug in demo app for memory managment