refactored code, and changed demonstration

refactored code and changed demonstration