Finally a working version. Lot needs to be done