Adding first working version of code