more demo code refactoring