Use the typedef that was provided for this purpose
Simplify output device check
Protect against invalid input values