Replace the check for the correct input type with more elegant code.