First complete working version