New Working version of code