Working version of the Code