refactored code and added demo project