working version with demo