Moving the code for generating the devices list into a function so that it can be reused
Useless JSON.parse
Merging and solving conflicts