Changed some of the device js to make it work better in jquery