added handling of input errors