Updating with the latest working code