latest working code