Added robust error handling for input exceptions