complete working version