At least it works
Initial working version