all working code