adding logic to script to check for devices before loading