More explicit handling of invalid input