Refactor device.js into multiple controllers