Complete working version