First, completely working version