Refactor code for demo project