Updated with support for multiple devices.
Cleaned to remove redundant grep call.