Almost working version
Improved style