refactored demo