Ensure non-string input is also detected
Simplified logic for detecting invalid input