The working code