First working version . Still not completed though