Updated the register device function