Update Device Code to working code