Improved input error handling